
<script language="JavaScript" type="text/javascript"><!--
function keyPressIntermediary(evt) {
  return M_keyPress(evt);
}
document.onkeypress = keyPressIntermediary;

logged_in = <%= logged_in? ? 'true' : 'false' %>;
login_warned = false;

// -->
</script>

<!-- Form used by in-line comment JS; XXX filled in by JS code -->
<% form_tag({:controller => :issue, :action => :inline_draft}, :method => :post, :id => "dainlineform", :style => "display: none;") do %>
  <div class="comment-border" name="form-container">
    <%= hidden_field :comment, :snapshot %>
    <%= hidden_field :comment, :line %>
    <%= hidden_field :comment, :side %>
    <%= hidden_field :issue, :id %>
    <%= hidden_field :patchset, :id %>
    <%= hidden_field :patch, :id %>
    <%= text_area :comment, :text, :cols => 60, :rows => 5 %>
    <br>

    <input type="submit" name="save" value="Save"
           onclick="return M_submitInlineComment(this.form);">
    <input type="reset" name="cancel" value="Cancel"
           onclick="M_removeTempInlineComment(this.form)">
  </div>
  <div class="comment-border" style="padding: 0pt;"></div>
<% end %>
<a id="resizer" style="display:none;cursor:pointer"><%= image_tag "zippyplus.gif" %></a>

<h2><%=h _("File: ")%><%=h @patch.filename %></h2>

<div>
  <b>Issue:</b>
  <%= link_to @issue.subject,{:controller => :issue, :action => :view, :id => @issue.id}, :id => "upCL" %>
  ('u')
</div>
<div>
  <i><%=h _("Created:")%></i> <%=h _("%{timeago} by %{user}") % {:timeago => timeago(@issue.created_at), :user => (logged_in? && @issue.user_id == self.current_user.id) ? _("me") : @issue.user.login} %>
  <i><%=h _("Last updated:")%></i> <%= timeago @issue.updated_at %>
</div>

<div><i><%=h _("SVN Base:")%></i> <%= @issue.base %></div>
<div><i><%=h _("Reviewers:")%></i> <%= @issue.reviewer_string %></div>
<div>
  <b><%=h _("Patch Set: ")%><%= @patchset.message %></b>
</div>

<div>
  <i><%=h _("Created:")%></i> <%= timeago @patchset.created_at %>
</div>

<p>
<% if @p_patch %>
  <%= link_to "&laquo; #{@p_patch.filename}", :controller => :issue, :action => :diff, :id => @issue.id, :psid => @patchset.id, :pid => @p_patch.id %> ('k')
<% else %>
<span class="disabled">&laquo; no previous file</span>
<% end %>
|
<% if @n_patch %>
  <%= link_to "#{@n_patch.filename} &raquo;", :controller => :issue, :action => :diff, :id => @issue.id, :psid => @patchset.id, :pid => @n_patch.id %> ('j')
<% else %>
<span class="disabled">no next file &laquo;</span>
<% end %>
|
<%= link_to _("View unified diff"), :controller => :issue, :action => :patch, :id => @issue.id, :psid => @patchset.id, :pid => @patch.id %>
|

<a href="javascript:if (intraLineDiff) intraLineDiff.toggle()">
Toggle Intra-line Diffs</a> ('i')
|
<a href="javascript:M_expandAllInlineComments()">Expand Comments</a> ('e')
|
<a href="javascript:M_collapseAllInlineComments()">Collapse Comments</a> ('c')
|
<a id="show-all-inline"
   style="display:none"
   href="javascript:M_showAllInlineComments()">Show Comments</a>
<a id="hide-all-inline"
   href="javascript:M_hideAllInlineComments()">Hide Comments</a> ('s')

|
<%= link_to _("Publish+Mail Comments"),{:controller => :issue, :action => :publish, :id => @issue.id}, :class => "novisit" %>
</p>

<h3><%=h _("Side by Side Diff")%></h3>

<p><i><%=h _("Use n/p to move between diff chunks;N/P to move between comments.Double-click a line to add a draft in-line comment.")%>
<br>
<% if logged_in? && Comment.count(:conditions => ['user_id = ? and draft = 1', self.current_user.id]) > 0 %>
<span style="color:red"><%= _("Draft comments are only viewable by you.")%></span>
<%= _("use %{publish} to let others view them.") % {:publish => link_to(_("Publish+Mail Comments"),{:controller => :issue, :action => :publish, :id => @issue.id}, :class => "novisit")} %>
<% end %>
</i></p>

<div style="position:relative" id="table-top">

<span id="hook-sel" style="display:none;"></span>

<table border="0" cellpadding="0" cellspacing="0" id="thecode"
       ondblclick="M_handleTableDblClick(event)">

<tr><th><%=h _("OLD")%></th><th><%=h _("NEW")%></th></tr>

<% 
   old_lineno = 1
   new_lineno = 1
   length = [@new.length.to_s.split("").size, @old.length.to_s.split("").size].max
   [@new.length, @old.length].max.times {|i|
     up_old = false
     up_new = false
%>
  <tr <%= 'name="hook"' unless @old[i] == @new[i]%> id="pair-<%= i %>">
    <td <%= @old[i] ? "id=\"oldcode#{old_lineno}\"" : "" %>  class="<%= line_class(@old[i], @new[i], true) %>">  <% unless @old[i].nil? %><%= @old[i] == @new[i] ? sprintf("%#{length}s", old_lineno) : "<u>"+sprintf("%#{length}s", old_lineno) + "</u>" %><% up_old = true %><% end %> <%=h fold @old[i].to_s, 73 %></td>
    <td <%= @new[i] ? "id=\"newcode#{new_lineno}\"" : "" %> class="<%= line_class(@old[i], @new[i], false) %>">  <% unless @new[i].nil? %><%= @old[i] == @new[i] ? sprintf("%#{length}s", new_lineno) : "<u>"+sprintf("%#{length}s", new_lineno) + "</u>" %><% up_new = true %><% end %> <%=h fold @new[i].to_s, 73 %></td>
  </tr>
  <tr class="inline-comments">
    <td <%= up_old ? "id=\"old-line-#{old_lineno}\"" : "" %>>
      <% if @comments["#{old_lineno}a"] %>
        <% @comments["#{old_lineno}a"].each {|c| %>
	  <%= render :partial => 'comment_view', :locals => {:comment => c} %>
	<% } %>
      <% end %>
    </td>
    <td <%= up_new ? "id=\"new-line-#{new_lineno}\"" : "" %>>
      <% if @comments["#{new_lineno}b"] %>
        <% @comments["#{new_lineno}b"].each {|c| %>
	  <%= render :partial => 'comment_view', :locals => {:comment => c} %>
	<% } %>
      <% end %>
    </td>
  </tr>
  <% old_lineno += 1 if up_old %>
  <% new_lineno += 1 if up_new %>
  <% } %>

<tr><th>OLD</th><th>NEW</th></tr>

</table>

</div>

<p>
<% if @p_patch %>
  <%= link_to "&laquo; #{@p_patch.filename}", :controller => :issue, :action => :diff, :id => @issue.id, :psid => @patchset.id, :pid => @p_patch.id %> ('k')
<% else %>
<span class="disabled">&laquo; no previous file</span>
<% end %>
|
<% if @n_patch %>
  <%= link_to "#{@n_patch.filename} &raquo;", :controller => :issue, :action => :diff, :id => @issue.id, :psid => @patchset.id, :pid => @n_patch.id %> ('j')
<% else %>
<span class="disabled">no next file &laquo;</span>
<% end %>
|
<%= link_to _("View unified diff"), :controller => :issue, :action => :patch, :id => @issue.id, :psid => @patchset.id, :pid => @patch.id %>
|

<a href="javascript:if (intraLineDiff) intraLineDiff.toggle()">
Toggle Intra-line Diffs</a> ('i')
|
<a href="javascript:M_expandAllInlineComments()">Expand Comments</a> ('e')
|
<a href="javascript:M_collapseAllInlineComments()">Collapse Comments</a> ('c')
|
<a id="show-all-inline"
   style="display:none"
   href="javascript:M_showAllInlineComments()">Show Comments</a>
<a id="hide-all-inline"
   href="javascript:M_hideAllInlineComments()">Hide Comments</a> ('s')

|
<%= link_to _("Publish+Mail Comments"),{:controller => :issue, :action => :publish, :id => @issue.id}, :class => "novisit" %>
</p>

</script>
<script language="JavaScript" type="text/javascript"><!--
var old_snapshot = "old";
var new_snapshot = "new";
var intraLineDiff = new M_IntraLineDiff();
var hookState = new M_HookState(window);
hookState.updateHooks();
// -->
</script>
